﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SchoolManagementSystem.Controls;
using SchoolManagementSystem.Forms.BusinessForm;
using CoreData;
using System.Reflection;
using ActionServices;

namespace SchoolManagementSystem.Details
{
    public partial class Stock_VoucherInUC : DetailUC
    {
        public Stock_VoucherInUC()
        {
            InitializeComponent();
            gridControl1.DataSource= CreateTable(3);
        }

        private void cmdaddproduct_Click(object sender, EventArgs e)
        {
            frmSelectProduct pro = new frmSelectProduct();
            if (pro.ShowDialog() == DialogResult.OK)
            {
                long idd = pro.ProductSeletedIDs[0];
                Product product = (Product)RegisterService.RegisterServices.ProductService.GetByID(idd);
                List<Product> lproduct = (List<Product>)RegisterService.RegisterServices.ProductService.GetList();
                
            }
            else
            {

            }
        }
        private DataTable CreateTable(int RowCount)
        {
            DataTable tbl = new DataTable();
            tbl.Columns.Add("ProductName", typeof(string));
            tbl.Columns.Add("ProductID", typeof(int));
            tbl.Columns.Add("ProductCode", typeof(string));
            tbl.Columns.Add("Quantity", typeof(int));
            tbl.Columns.Add("Price", typeof(decimal));
            //for (int i = 0; i < RowCount; i++)
               // tbl.Rows.Add(new object[] { String.Format("Name{0}", i), i, 3 - i, 1,1 });
            return tbl;
        }
        private void addNewRowInGroupMode(DevExpress.XtraGrid.Views.Grid.GridView View)
        {
            int rowHandle = View.GetDataRowHandleByGroupRowHandle(View.FocusedRowHandle);
            object[] groupValues = null;
            int groupColumnCount = View.GroupedColumns.Count;
            
            if (groupColumnCount > 0)
            {
                groupValues = new object[groupColumnCount];
                for (int i = 0; i < groupColumnCount; i++)
                {
                    groupValues[i] = View.GetRowCellValue(rowHandle, View.GroupedColumns[i]);
                }
            }
            View.AddNewRow();
            //Get the handle of the new row 
            int newRowHandle = View.FocusedRowHandle;
            object newRow = View.GetRow(newRowHandle);
            //Set cell values corresponding to group columns 
            if (groupColumnCount > 0)
            {
                for (int i = 0; i < groupColumnCount; i++)
                {
                    View.SetRowCellValue(newRowHandle, View.GroupedColumns[i], groupValues[i]);
                }
            }
            //Accept the new row 
            //The row moves to a new position according to the current group settings 
            View.UpdateCurrentRow();
            //Locate the new row 
            for (int n = 0; n < View.DataRowCount; n++)
            {
                if (View.GetRow(n).Equals(newRow))
                {
                    View.FocusedRowHandle = n;
                    break;
                }
            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            gridView1.AddNewRow();
            int newRowHandle = gridView1.FocusedRowHandle;

            gridView1.SetRowCellValue(newRowHandle, gridView1.Columns[0], "3rd Party %");
            gridView1.SetRowCellValue(newRowHandle, gridView1.Columns[1], 123);
            gridView1.SetRowCellValue(newRowHandle, gridView1.Columns[2], 23);
            gridView1.SetRowCellValue(newRowHandle, gridView1.Columns[3], 3);
            gridView1.SetRowCellValue(newRowHandle, gridView1.Columns[4], 3);
            gridView1.UpdateCurrentRow();
            gridView1.RefreshData();
        }
    }
}